1 program problem11203 (input, output);
\r
6 Function StrToInt(Const S: String): Integer;
\r
14 function formadaPor(s : string; c : char) : boolean;
\r
19 for i := 1 to length(s) do
\r
29 function isAxiom(x, y, z : string) : boolean; overload;
\r
32 if (length(x) + 1) <> (length(z)) then
\r
37 function isTheorem(s : string) : boolean;
\r
44 while ((s[i] <> 'M') and (i <= length(s))) do
\r
50 if (x = '') or (not formadaPor(x, '?')) then
\r
56 s := copy(s, i, length(s)); //delete from the beggining until the character before the first M
\r
63 s := copy(s, 2, length(s)); //delete the M
\r
66 while ((s[i] <> 'E') and (i <= length(s))) do
\r
72 if (y = '') or (not formadaPor(y, '?')) then
\r
78 s := copy(s, i, length(s)); //delete from the beggining until the character before the first E
\r
85 z := copy(s, 2, length(s)); //delete the E
\r
86 if not formadaPor(z, '?') then
\r
93 if length(y) = 1 then
\r
94 result := isAxiom(x, y, z)
\r
97 y := copy(y, 1, length(y) - 1); //borra el ultimo
\r
98 z := copy(z, 1, length(z) - 1);
\r
99 result := isTheorem(x+'M'+y+'E'+z);
\r
105 i, j, principalLoop : integer;
\r
107 letrasCorrectas : Set of char;
\r
111 //reset(input, 'input.txt');
\r
112 //reset(output, 'out.txt');
\r
114 letrasCorrectas := ['M', 'E', '?'];
\r
116 cuantos := strToInt(entrada);
\r
118 for principalLoop := 1 to cuantos do
\r
122 j := length(entrada);
\r
124 if not (entrada[i] in letrasCorrectas) then
\r
130 writeLn('no-theorem')
\r
133 if isTheorem(entrada) then
\r
136 writeLn('no-theorem');
\r